package com.edu.service.impl;

import com.edu.javaBean.MedicalRecord;
import com.edu.mapper.MedicalRecordMapper;
import com.edu.service.MedicalRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
@Service
public class MedicalRecordServiceImpl implements MedicalRecordService {
    @Autowired
    private MedicalRecordMapper medicalRecordMapper;

    @Override
    public Map<String, Object> getRecors(Map<String, Object> map) {
        return medicalRecordMapper.getRecord(map);
    }

    @Override
    public int saveRecord(MedicalRecord record) {
        //判断记录是否存在，存在更新，不存在插入
        Map map=new HashMap();
        map.put("casenumber",record.getCasenumber());
        map.put("registid",record.getRegistid());
        Map<String,Object> resMap=medicalRecordMapper.getRecord(map);
        int i=0;
        if(resMap==null){
            //插入
            medicalRecordMapper.insertSelective(record);
        }else{
            //更新
            medicalRecordMapper.updateRecord(record);
        }
        return i;
    }
}
